home *** CD-ROM | disk | FTP | other *** search
- Path: galaxy.ucr.edu!not-for-mail
- From: thp@cs.ucr.edu (Tom Payne)
- Newsgroups: comp.lang.c++
- Subject: Re: Will JAVA kill C++?
- Date: 15 Mar 1996 23:04:10 GMT
- Organization: University of California, Riverside
- Message-ID: <4ict1a$skr@galaxy.ucr.edu>
- References: <313E44EA.14D110C0@netcom.com> <4hp18v$3di@frodo.smartlink.net>
- NNTP-Posting-Host: corvette.ucr.edu
- X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
-
- Matt Austern (austern@isolde.mti.sgi.com) wrote:
- : In article <4hqkfk$20j@galaxy.ucr.edu> thp@cs.ucr.edu (Tom Payne) writes:
- :
- : > : In C++, or Fortran, or Eiffel, you can have an array of complex
- : > : numbers. In Java, though, you can't: you can have something that
- : > : looks like an array of complex numbers, but internally it's really an
- : > : array of pointers to complex numbers. You have to pay a space penalty
- : > : to store those pointers, and a time penalty to do the dereferencing on
- : > : every element, and the optimizer will have to generate code on
- : > : assumption that two array elements might point to the same object.
- : >
- : > Are these references resettable? If not, how can they be made to
- : > collide like that? In fact, if they are not resettable, is there
- : > any reason that the extra level of indirection couldn't be
- : > optimized away?
- :
- : public class complex
- : {
- : public complex(double re, double im)
- : {
- : Re = re;
- : Im = im;
- : }
- :
- : public double Re;
- : public double Im;
- : }
- :
- :
- : class F
- : {
- : static public void f()
- : {
- : complex[] A = new complex[3];
- : A[0] = new complex(1, 1);
- : A[1] = new complex(0, 1);
- : A[2] = A[0]; // A[0] and A[2] point to the same object.
-
- Ah so!!
-
- : I don't see that Java solves any aliasing problems. It does have
- : pointers, and the fact of pointer semantics is very clearly visible to
- : the user in many different ways. I don't see how you could optimize
- : away anything so fundamental and pervasive; if you're able to write an
- : optimizer that can perform heroics like that, then dealing with the
- : aliasing problems in C and C++ would be trivial.
-
- Yup! In the presence of such reference-induced aliasing, the
- indirection cannot be ignored, making life much more difficult for the
- optimizer. (Index-induced aliasing already makes it difficult
- enough.)
-
- Tom Payne (thp@cs.ucr.edu)
-
-